class WapController < ApplicationController
  before_filter :set_cookies_or_url
  after_filter :log_filter,:except => [:index]
  layout "wap"
  include WapHelper
  def index   
    redirect_to params.merge!(:action => 'show')
  end

  def show
    params[:cn] = params[:cn].to_i + 1
    @oper_type = 1
    @img_style = params[:img_style]
    if @img_style.nil?
      @img_style = 1
    end
    @pp_style = params[:pp_style]
    if @pp_style.nil?
      @pp_style = 1
    end
    @pp_num = params[:pp_num]
    if @pp_num.nil?
      @pp_num = 2
    end
    host = request.domain
    puts "----------------------------------{host}"
    le = $level_map[host.swapcase]
    #普通频道
    @channels = Channel.find :all , :conditions => ['status = 1 and channel_type = 1'], :order => 'orders asc'
    #专辑频道
    @channels_al = Channel.find :all , :conditions => ['status = 1 and channel_type = 2'], :order => 'orders asc'
    @channel_al = nil
    if @channels_al.size > 0
      @channel_al = @channels_al[0]
    end
    #精选频道
    @channel_chose = nil
    channel_choses = Channel.find :all , :conditions => ['status = 1 and channel_type = 3'], :order => 'orders asc'
    if channel_choses.size > 0
      @channel_chose = channel_choses[0]
    end
    @titles = le[:name]+request.domain
    respond_to do |format|      
      format.wml
    end
  end 

  def mark
    params[:cn] = params[:cn].to_i + 1
    @oper_type = 2
    @img_style = params[:img_style]
    if @img_style.nil?
      @img_style = 1
    end
    @pp_style = params[:pp_style]
    if @pp_style.nil?
      @pp_style = 1
    end
    @pp_num = params[:pp_num]
    if @pp_num.nil?
      @pp_num = 2
    end
    host = request.domain
    le = $level_map[host.swapcase]
    @titles = "保存"+le[:name]+"到手机"
    respond_to do |format|
      format.wml
    end
  end

  #免责
  def disclaimer
    params[:cn] = params[:cn].to_i + 1
    @img_style = params[:img_style]
    if @img_style.nil?
      @img_style = 1
    end
    @pp_style = params[:pp_style]
    if @pp_style.nil?
      @pp_style = 1
    end
    @pp_num = params[:pp_num]
    if @pp_num.nil?
      @pp_num = 2
    end
    host = request.domain
    le = $level_map[host.swapcase]
    @titles = "关于"
    respond_to do |format|
      format.wml
    end
  end  

  #客服中心
  def service
    params[:cn] = params[:cn].to_i + 1
    @oper_type = 99
    @img_style = params[:img_style]
    if @img_style.nil?
      @img_style = 1
    end
    @pp_style = params[:pp_style]
    if @pp_style.nil?
      @pp_style = 1
    end
    @pp_num = params[:pp_num]
    if @pp_num.nil?
      @pp_num = 2
    end
    host = request.domain
    le = $level_map[host.swapcase]
    @titles = "客服中心"
    @msg = params[:msg]
    @rt_msg = ""
    if !@msg.nil? && !@msg.empty?
      @rt_msg = "成功提交!网站客服将尽快处理相关问题!<br/>"
    else
      @rt_msg = nil
    end
    respond_to do |format|
      format.wml
    end
  end  

end
